package com.zhiyou100.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhiyou100.model.Star;
import com.zhiyou100.service.StarService;
import com.zhiyou100.vo.ResponseVo;

@RestController
public class StarController {
	@Autowired
	private StarService starService;
	@PostMapping("/stars")
	public ResponseVo<String> add(@RequestBody Star star){
		starService.add(star);
		return new ResponseVo<String>(200, "添加成功", null);
	}
	@DeleteMapping("/stars/{id}")
	public ResponseVo<String> delete(@PathVariable int id){
		starService.delete(id);
		return new ResponseVo<String>(200, "删除成功", null);
	}
	@GetMapping("/stars/{userId}")
	public ResponseVo<String> findAll(@PathVariable int userId){
		starService.findAll(userId);
		return new ResponseVo<String>(200, "请求成功", null);
	}
}
